import smap.archiver.client
import time
import scipy.interpolate
import csv
import calendar

#change the name and location of the output file
f1 = open('/home/cbe/.gvfs/bsg on 169.229.130.74/New York Times/Analysis/sensorList.csv', 'wb')
testsout = csv.writer(f1,dialect='excel') 

#input stream ids
c = smap.archiver.client.SmapClient(base='http://new.openbms.org/backend', key='SA2nYWuHrJxmPNK96pdLKhnSSYQSPdALkvnA', private=True)

headings = []
headings.append(['uuid'])
headings.append(['sensor type'])
headings.append(['sensor height'])
headings.append(['device'])
headings.append(['pmp category'])
headings.append(['mote']) 
headings[0].extend(c.query('select distinct uuid where Metadata/SourceName = \'CBE Vigilent Motes\' and Metadata/Location/Building = \'New York Times\''))
for uuid in headings[0]:
    headings[1].extend(c.query('select distinct Metadata/Extra/SensorType where uuid = \'%s\'' % uuid))
    headings[2].extend(c.query('select distinct Metadata/Extra/SensorLocation where uuid = \'%s\'' % uuid))
    headings[3].extend(c.query('select distinct Metadata/Extra/DeviceName where uuid = \'%s\'' % uuid))
    headings[4].extend(c.query('select distinct Metadata/Extra/PmpCategory where uuid = \'%s\'' % uuid))
    headings[5].extend(c.query('select distinct Path where uuid = \'%s\'' % uuid))

transposed = zip(*headings)
for x in xrange(len(transposed)):
    testsout.writerow(transposed[x])

f1.close()


